package com.mr.qa.bo;

import java.util.Date;
import java.util.List;

import com.mr.qa.dao.impl.ShopArticleHistoryDAO;

public class ShopArticleHistory extends BaseBO {
	private User user;
	private ShopArticle article;
	private Date date;
	private Integer money;
	private String realName;
	private String telephone;
	private String company;
	private String postAddr;
	private String postCode;
	private String email;
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	public ShopArticle getArticle() {
		return article;
	}
	public void setArticle(ShopArticle article) {
		this.article = article;
	}
	public Date getDate() {
		return date;
	}
	public void setDate(Date date) {
		this.date = date;
	}
	public Integer getMoney() {
		return money;
	}
	public void setMoney(Integer money) {
		this.money = money;
	}
	public String getRealName() {
		return realName;
	}
	public void setRealName(String realName) {
		this.realName = realName;
	}
	public String getTelephone() {
		return telephone;
	}
	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}
	public String getCompany() {
		return company;
	}
	public void setCompany(String company) {
		this.company = company;
	}
	public String getPostAddr() {
		return postAddr;
	}
	public void setPostAddr(String postAddr) {
		this.postAddr = postAddr;
	}
	public String getPostCode() {
		return postCode;
	}
	public void setPostCode(String postCode) {
		this.postCode = postCode;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	
	public void add(){
		ShopArticleHistoryDAO dao = new ShopArticleHistoryDAO();
		dao.save(this);
	}
	
	public Integer getCountByArticleId(Integer articleId){
		ShopArticleHistoryDAO dao = new ShopArticleHistoryDAO();
		String whereClause = null;
		if(articleId != null){
			whereClause = "where article.id = " + articleId;
		}
		return dao.countHistory(whereClause);
	}
	
	public List getByArticleId(Integer articleId, int page, int pageSize){
		ShopArticleHistoryDAO dao = new ShopArticleHistoryDAO();
		if(page > 0 && pageSize > 0){
			dao.setPage(page, pageSize);
		}
		String whereClause = null;
		if(articleId != null){
			whereClause = "where article.id = " + articleId;
		}
		String orderClause = "order by id desc";
		return dao.getHistoryList(whereClause, orderClause);
	}
	
}
